﻿#include "fileitem.h"
#include "ui_fileitem.h"

FileItem::FileItem(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::FileItem)
{
    ui->setupUi(this);
}

FileItem::~FileItem()
{
    delete ui;
}

void FileItem::SetHead(const QString &filetype)
{
    ui->label_file->setScaledContents(true);
    ui->label_file->setPixmap(QPixmap(":/img/file.png"));
}

void FileItem::SetFileName(const QString &filename)
{
    ui->label_filename->setText(filename);
}

void FileItem::SetFileSize(const QString &filesize)
{
    ui->label_filesize->setText(filesize);
}

void FileItem::SetFileType(const QString &filetype)
{
    ui->label_type->setText(filetype);
}

void FileItem::SetTime(const QString &time)
{
    ui->label_changetime->setText(time);
}

void FileItem::SetSelect()
{
    if (ui->checkBox->checkState() == Qt::Unchecked)
    {
        ui->checkBox->setCheckState(Qt::Checked);
    }
    else
    {
        ui->checkBox->setCheckState(Qt::Unchecked);
    }
}

QString FileItem::GetFileName()
{
    return ui->label_filename->text();
}

void FileItem::mousePressEvent(QMouseEvent *event)
{
    // 将鼠标事件传递给父级，确保复选框可以正常响应
    QWidget::mousePressEvent(event);
}
